package yannan.voiplock4ble.bean.ble;

import yannan.voiplock4ble.utils.ByteUtils;

/**
 * 说明：开锁
 * 作者：mainTel
 * 时间：2016/12/6 09:44
 * 备注：
 */
public class UnLockRecord extends BaseBleResponse {

    /*
      typedef union{
            uint8_t phone[FINGER_ID_MAX_LENGTH+1];	//（指静脉手机号为11Byte）
            uint8_t pwdID;
        }UserNumber;
            //开锁记录发送
        typedef struct {
            AppCommandHead_T head;
            uint8_t cmd;
            uint8_t reserve;	//对齐保留
            uint16_t token;
        //开锁类型
        #define 	ADMIN_FINGER_UNLOCK		0		//指静脉管理员开锁
        #define 	NORMAL_FINGER_UNLOCK	1		//指静脉普通用户开锁
        #define	USER_PWD_UNLOCK			2		//密码用户开锁
            uint8_t unlockType;		//开锁类型
            UserNumber userNumber;
            uint32_t timeStamp;
        }UnlockRecordSend_T;
    5A A5 19 00 00 00 07 00 45 A0
    02
    0A 00 00 00 00 00 00 00 00 00 00 00
    75 9E 85 B2
    72 91
     */

    public int unlockType;
    public long timeStamp;
    public String userNumber;

    public UnLockRecord(byte[] response) {
        super(response);
        unlockType = content[0] & 0xff;
        if (unlockType == 2) {
            userNumber = (content[1] & 0xff) + "";
        } else {
            byte[] number = new byte[11];
            for (int i = 1; i <= 11; i++) {
                number[i - 1] = content[i];
            }
            userNumber = new String(number);
        }
        timeStamp = Long.parseLong(
                ByteUtils.bytesToHexString(
                        new byte[]{content[16], content[15], content[14], content[13]}), 16);

    }
}
